package com.cortex.papaya.view;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

import android.content.ClipData;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.graphics.drawable.PaintDrawable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnLongClickListener;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.GridLayout;
import android.widget.GridLayout.Spec;
import android.widget.HorizontalScrollView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.cortex.papaya.search.Categories;
import com.cortex.papaya.search.Category;
import com.cortex.papaya.search.Link;
import com.cortex.papayasearch.R;

public class CategoryView extends RelativeLayout {

	private Category category;
	private TextView tvCategoryName,tvCountDocuments;

	public CategoryView(Context context) {
		super(context);
	}
	public CategoryView(Context context, AttributeSet attrs) {
		super(context, attrs);
	}

	public CategoryView(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
	}
	@Override
	protected void onFinishInflate() {
		super.onFinishInflate();
		initViews();
		initHandlers();
	}
	private void initHandlers(){

	}
	private void initViews(){
		tvCategoryName = (TextView)findViewById(R.id.tvCategoryName);
		tvCountDocuments = (TextView)findViewById(R.id.tvCountDocuments);
	}
	public Category getCategory() {
		return category;
	}
	public void setCategory(Category category) {
		this.category = category;
		tvCategoryName.setText(category.getName());
		tvCountDocuments.setText("(" + category.getCountLinks() + " results)");
		setBackgroundResource(category.getColor());
	}

	
}
